package com.smyh.server;

import android.os.AsyncTask;

import com.smyh.common.CommState;
import com.smyh.common.MinaClientThread;

/**
 * Created by Administrator on 2016/7/20.
 */
public class CommunAsyncTask extends AsyncTask {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Object doInBackground(Object[] params) {
        //射频设备连接服务：
        if(CommState.deivceCommOpen){
            new Thread(new MinaClientThread()).start();
        }
        while (true){

            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (MinaClientThread.session == null||MinaClientThread.session.isClosing()){

                if(CommState.deivceCommOpen){
                    MinaClientThread.reConnect();
                }

            }else if(2>3){
                break;
            }
        }
        return null;
    }

    @Override
    protected void onProgressUpdate(Object[] values) {
        super.onProgressUpdate(values);
    }

    @Override
    protected void onPostExecute(Object o) {
        super.onPostExecute(o);
    }
}
